package com.yt.order.service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.yt.order.models.dto.WorkOrderInfoDTO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import javax.annotation.Resource;
import com.yt.order.common.config.YmlConfig;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yt.order.mapper.WorkOrderEvaluationMapper;
import com.yt.order.models.service.IWorkOrderEvaluationService;
import com.yt.order.models.bo.WorkOrderEvaluationSaveBO;
import com.yt.order.models.dto.WorkOrderEvaluationDTO;

import java.util.List;

/**
 * 工单评论表控制器
 *
 * @author zhou
 * @Date 2025-09-14 10:03:32
 */
@DubboService
public class WorkOrderEvaluationServiceImpl extends ServiceImpl<WorkOrderEvaluationMapper, WorkOrderEvaluationDTO> implements IWorkOrderEvaluationService{

    @Resource
    private YmlConfig ymlConfig;

    @Override
    public boolean add(WorkOrderEvaluationSaveBO saveBO) {
        WorkOrderEvaluationDTO dto = new WorkOrderEvaluationDTO();
        BeanUtils.copyProperties(saveBO,dto);
        Long id = ymlConfig.getPkId();
        dto.setId(id);
        return this.insert(dto);
    }
    @Override
    public List<WorkOrderEvaluationDTO> selectByWorkOrderId(Long workOrderId) {
        Wrapper<WorkOrderEvaluationDTO> wrapper = new EntityWrapper<>();
        wrapper.eq("work_order_id", workOrderId); // 假设字段名为work_order_id
        return baseMapper.selectList(wrapper);
    }

    @Override
    public WorkOrderEvaluationDTO addEva(WorkOrderInfoDTO workOrderInfoDTO) {
        WorkOrderEvaluationDTO dto = new WorkOrderEvaluationDTO();
        dto.setId(ymlConfig.getPkId());
        dto.setWorkOrderId(workOrderInfoDTO.getId());
        dto.setUserId(workOrderInfoDTO.getCustomerId());
        dto.setEmpId(workOrderInfoDTO.getEmployeeId());
        dto.setServiceQuality(5);
        dto.setServiceAttitude(5);
        dto.setServiceSpeed(5);
        dto.setContent("好");

        return dto;
    }
}
